const Router = require('koa-router');  
const router = new Router();  
const UserController = require('../../controllers/user.js')
const path = require('path')
const multer = require('koa-multer')

const storage = multer.diskStorage({
    destination: (req, file, cb) => {
      cb(null,path.join(__dirname ,'../../upload'))
    },
    filename: (req, file, cb) => {
      let fileFormat = (file.originalname).split(".");
        cb(null,Date.now() + "." + fileFormat[fileFormat.length - 1]);
    }
  })
  const upload = multer({
    storage
  });


router
.get('/getUserList',UserController.getUserList)
.post('/addUser',UserController.addUser)
.post('/upload',upload.single('file'),UserController.upload)
.post('/login',UserController.login)
.post('/delUser',UserController.delUser)
  
module.exports = {  
  routes: () => router.routes(),  
  allowedMethods: () => router.allowedMethods(),  
};